<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:form id="formCO">
	<script type="text/javascript">
		
	</script>
	<p:panel header="#{message.header_cadastro_orca}"
		style="position: relative; left:10%;">
		<div class="ym-grid">
			<div style="left: 50%; margin-left: -300px; position: relative;">
				<div class="ym-g20 ym-gl">
					<div class="ym-gbox">
						<h:outputLabel value="#{message.label_dt_emissao}"></h:outputLabel>
					</div>
					<div class="ym-gbox">
						<p:inputMask id="idEmiDt" value="#{orcamentoTela.dtEmissao}"
							size="6" maxlength="8" style="font-size: 13px;" mask="99/99/99"
							required="true" readonly="true"
							requiredMessage="#{message.msg_obrigatorio}">
							<p:ajax event="blur" update="idEmiDt" process="@this"
								global="false" />
						</p:inputMask>
					</div>
				</div>
				<div class="ym-g20 ym-gl">
					<div class="ym-gbox">
						<h:outputLabel value="#{message.label_dt_validade}"></h:outputLabel>
					</div>
					<div class="ym-gbox">
						<p:inputMask id="idValDt" value="#{orcamentoTela.dtValidade}"
							size="6" maxlength="8" style="font-size: 13px;" mask="99/99/99"
							required="true" validator="#{orcamentoTela.validador}"
							requiredMessage="#{message.msg_obrigatorio}">
							<p:ajax event="blur" update="idValDt" process="@this"
								global="false" />
						</p:inputMask>
					</div>

				</div>
				<div class="ym-g20 ym-gl">
					<div class="ym-gbox">
						<h:outputLabel value="#{message.label_tipo}"></h:outputLabel>
					</div>
					<div class="ym-gbox">

						<p:selectOneMenu style="margin-right:15px;width:150px;"
							value="#{orcamentoTela.tipo.codigo}" required="true"
							requiredMessage="#{message.msg_obrigatorio}">
							<f:selectItem itemLabel="" itemValue="0" />
							<f:selectItems value="#{orcamentoTela.preencheCombo}" var="tipo"
								itemLabel="#{tipo.descricao}" itemValue="#{tipo.codigo}" />
						</p:selectOneMenu>
					</div>
				</div>
			</div>
		</div>

		<div class="ym-grid" style="margin-top: 10px;">
			<div style="left: 50%; margin-left: -300px; position: relative;">
				<div style="display: table-cell; padding-left: 10px;">
					<h:outputLabel value="#{message.label_produto}"></h:outputLabel>
					<br />
					<p:inputText id="idProdCad" value="#{orcamentoTela.produto.codigo}"
						required="true" size="7" validator="#{orcamentoTela.validador}"
						requiredMessage="#{message.msg_obrigatorio}">
						<p:ajax event="blur" update="idProdCad,idDesCad,idUmCad,idMarCad"
							process="@this" global="false" />
					</p:inputText>
					<p:commandButton icon="ui-icon-search" onclick="dlgConProd.show()">
					</p:commandButton>

					<p:inputText id="idMarCad" value="#{orcamentoTela.produto.marca}"
						size="10" readonly="true" />
					<p:inputText id="idDesCad"
						value="#{orcamentoTela.produto.descricao}" size="20"
						readonly="true" />
					<p:inputText value="#{orcamentoTela.produto.unidadeMedida}"
						size="2" readonly="true" id="idUmCad" />
				</div>
				<div style="display: table-cell; padding-left: 43px;">
					<h:outputLabel value="#{message.label_quantidade}"></h:outputLabel>
					<br />
					<p:inputText id="idQtd"
						value="#{orcamentoTela.itemOrcamento.quantidade}" required="true"
						size="12" converterMessage="ssss"
						requiredMessage="#{message.msg_obrigatorio}">
						<p:ajax event="blur" update="idQtd" process="@this" global="false" />
					</p:inputText>
				</div>
			</div>
			<div class="ym-g20 ym-gl" style="margin-top: 10px;">
				<div class="ym-g20 ym-gl">
					<p:commandButton value="#{message.botao_adicionar}"
						update="itens,:messages,@parent,@form,:formCO:idEmiDt"
						action="#{orcamentoTela.adicionaItem}" icon="ui-icon-plus">
						<p:collector value="#{orcamentoTela.itemOrcamento}"
							addTo="#{orcamentoTela.itensOrcamento}" />
					</p:commandButton>
				</div>
			</div>
		</div>

	</p:panel>

	<p:outputPanel id="itens" style="position: relative; left:10%;">
		<p:dataTable value="#{orcamentoTela.itensOrcamento}" var="item"
			emptyMessage="#{message.table_empty}" style="margin-top:20px;"
			paginator="true" rows="5">
			<p:column>
				<f:facet name="header">
					<h:outputText value="#{message.label_codigo}" />
				</f:facet>
				<h:outputText value="#{item.produto.codigo}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="#{message.label_marca}" />
				</f:facet>
				<h:outputText value="#{item.produto.marca}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="#{message.label_descricao}" />
				</f:facet>
				<h:outputText value="#{item.produto.descricao}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="#{message.label_um}" />
				</f:facet>
				<h:outputText value="#{item.produto.unidadeMedida}" />
			</p:column>


			<p:column>
				<f:facet name="header">
					<h:outputText value="#{message.label_quantidade}" />
				</f:facet>
				<h:outputText value="#{item.quantidade}" />
			</p:column>

			<p:column>
				<f:facet name="header">
					<h:outputText value="#{message.label_operacao}" />
				</f:facet>
				<p:commandButton id="btn_add" icon="ui-icon-trash"
					update=":formCO:itens" process=":formCO:itens">
					<p:collector value="#{item}"
						removeFrom="#{orcamentoTela.itensOrcamento}" />
				</p:commandButton>
				<p:tooltip for="btn_add" value="#{message.botao_excluir}" />
			</p:column>
		</p:dataTable>
	</p:outputPanel>

	<div style="margin-left: 380px; margin-top: 30px;">
		<p:commandButton update="itens,:messages,@parent,@form"
			value="#{message.botao_salvar}" icon="ui-icon-disk"
			action="#{orcamentoTela.salvar}" immediate="true" />
		<p:commandButton style="margin-left:20px;"
			value="#{message.botao_cancelar}" icon="ui-icon-cancel"
			action="#{orcamentoTela.cancelar}"
			update="itens,:messages,@parent,@form" immediate="true"
			oncomplete="jQuery('#panelOrcar').hide('slow');" />
	</div>

</h:form>
</html>